package com.pine.web.pineframework.controller;

import com.pine.common.beans.ResultVo;
import com.pine.common.beans.pineframework.request.SysApprovalHistoryQueryRequest;
import com.pine.common.beans.pineframework.response.SysApprovalHistoryQueryResponse;
import com.pine.common.beans.request.IdRequest;
import com.pine.common.beans.request.PageRequest;
import com.pine.common.beans.response.PageResponse;
import com.pine.common.systemlog.annotation.SysLog;
import com.pine.service.pineframework.SysApprovalHistoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 系统审批历史前端控制器
 * </p>
 *
 * @author pine manage
 * @since 2024-10-31
 */
@Tag(name = "系统审批历史前端控制器")
@RestController
@RequestMapping("/sys/approval/history")
public class SysApprovalHistoryController {
    @Resource
    private SysApprovalHistoryService sysApprovalHistoryService;

    /**
     * 分页查询
     *
     * @param request 请求
     * @return 分页响应
     */
    @Operation(summary = "分页查询")
    @PostMapping("/pages")
    @SysLog("分页查询")
    public ResultVo<PageResponse<SysApprovalHistoryQueryResponse>> listPages(@RequestBody @Valid PageRequest<SysApprovalHistoryQueryRequest> request) {
        request.defaultPage();
        return ResultVo.success(sysApprovalHistoryService.listPages(request));
    }

    /**
     * 查询信息（不分页）
     *
     * @param request 请求
     * @return PageResponse 响应
     */
    @Operation(summary = "查询信息（不分页）")
    @PostMapping("/list")
    @SysLog("查询信息（不分页）")
    public ResultVo<List<SysApprovalHistoryQueryResponse>> list(@RequestBody @Valid SysApprovalHistoryQueryRequest request) {
        return ResultVo.success(sysApprovalHistoryService.list(request));
    }

    /**
     * 查询详细信息
     *
     * @param request 请求
     * @return 响应
     */
    @PostMapping(value = "/detail")
    @Operation(summary = "查询详细信息")
    @SysLog("查询详细信息")
    public ResultVo<SysApprovalHistoryQueryResponse> getDetail(@RequestBody @Valid IdRequest<Long> request) {
        return ResultVo.success(sysApprovalHistoryService.getOneByUniqueKey(request.getId(), "id"));
    }
}
